package com.ape.mapsa.produccion.dao;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.ape.mapsa.produccion.model.Item;

@Repository
public class ItemDAOImpl extends GenericDAOImpl<Item, Long> implements ItemDAO {

	@Override
	public Item getByCode(String itemCode) {
		Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Item.class);
		criteria.add(Restrictions.eq("codigo", itemCode));
		criteria.add(Restrictions.eq("itemCategoria", "PT"));
		return (Item) criteria.uniqueResult();
	}

	@Override
	public List<Item> getAll() {
		Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Item.class);
		criteria.add(Restrictions.eq("itemCategoria", "PT"));
		return criteria.list();
	}

}
